package com.bwie.controller;
import com.bwie.mapper.UserMapper;
import com.bwie.pojo.Hotel;
import com.bwie.pojo.Room;
import com.bwie.pojo.User;
import com.bwie.service.UserService;
import com.bwie.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;

/**
* (t_user)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/t_user")
@Api(tags = {"登入"})
public class UserController {
/**
* 服务对象
*/
    @Autowired
    private UserService userService;


    @ApiOperation("验证码发送")
    @GetMapping("/getCode")
    public void getCode(){
        userService.getCode();
    }

    @ApiOperation("获取手机号短信")
    @PostMapping("/getPhone")
    public R getPhone(@RequestBody User user){
        return userService.getPhone(user);
    }

    @ApiOperation("登入表单")
    @PostMapping("/getLogin")
    public R getLogin(@RequestBody User user){
        return userService.getLogin(user);
    }

    @ApiOperation("通过手机号获取酒店信息")
    @PostMapping("/PhoneById")
    public R PhoneById(@RequestBody User user){
        return userService.PhoneById(user);
    }

    @ApiOperation("修改酒店信息")
    @PostMapping("/UpdateHotel")
    public R UpdateHotel(@RequestBody Hotel hotel){
        return userService.upDateHotel(hotel);
    }

    @ApiOperation("客房列表")
    @PostMapping("/getRoom")
    public R getRoom(@RequestBody Room room){
        return userService.getRoom(room);
    }

    @ApiOperation("查询字典表")
    @PostMapping("/getDict/{type}")
    public R getDict(@PathVariable("type")Integer type){
        return userService.getDict(type);
    }

    @ApiOperation("添加客房")
    @PostMapping("/RoomAdd")
    public R RoomAdd(@RequestBody @Validated Room room){
        return userService.roomAdd(room);
    }

    @ApiOperation("图片上传")
    @PostMapping("AddImgs")
    public R AddImgs(@RequestPart("file")MultipartFile file){
        return userService.AddImgs(file);
    }

}
